package com.vcredit.creditcat.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.vcredit.creditcat.bean.Session;
import com.vcredit.creditcat.exception.SessionException;

public class SessionInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {

		Session session = (Session) request.getSession().getAttribute("session");
		if (session == null) {
			throw new SessionException("会话超时，请重新登录");
		}
		return true;
	}
}
